//
//  RaidersTableCell.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/8/24.
//  Copyright © 2017年 AudioCtrip. All rights reserved.
//

#import "RaidersTableCell.h"

@implementation RaidersTableCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.guiderNameLabel.textColor = kSubitleColor;
    self.favCountLabel.textColor = kContentColor;
    self.BrowsedCountLabel.textColor = kContentColor;
    self.daysTagLabel.backgroundColor = kThemeColor;
//    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(favtap)];
//    
//    [self.favView addGestureRecognizer:tap];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)configData:(Raiders *)raider {
    
    self.nameLabel.text = raider.title;
    
    [self.raidersImageView setImageURL:[NSURL URLWithString:raider.pictureArray.firstObject] placeholderImage:[UIImage imageNamed:@"placeholder_rec"]];
    
    self.headerView.headerImageName = raider.guideheadimg;
    self.headerView.vip = raider.guidevip.integerValue;
    self.guiderNameLabel.text = raider.guidename;
    
    self.favCountLabel.text = raider.zantimes;
    self.BrowsedCountLabel.text = raider.seetimes;
    
    NSString *day = (raider.days.integerValue > 1 ? @"DAYS" : @"DAY");
    
    NSMutableAttributedString  * str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n%@",raider.days,day]];
    [str addAttribute:NSFontAttributeName
                    value:[UIFont systemFontOfSize:11.0f]
                    range:NSMakeRange(str.length - day.length, day.length)];
    
    self.daysTagLabel.attributedText = str;
}

//-(void)setFrame:(CGRect)frame
//{
//    frame.size.height -= 20;
//    [super setFrame:frame];
//}

- (void)favtap {
    
    self.isFav = !_isFav;
}

- (void)setIsFav:(BOOL)isFav {
    _isFav = isFav;
    if (isFav) {
        self.favImageView.image = [UIImage imageNamed:@"点赞"];
    }else {
         self.favImageView.image = [UIImage imageNamed:@"赞"];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
